﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Classes
{
    public class Searcher
    {
        IList<City> airports;
        IList<City> visited;
        IGraphImpl graph;
        //here I have some fields to work on our own data, of course we will get it rom 
       /* City aalborg;
        City copenhagen;
        City aarhus;
        City berlin;
        City budapest;
        City sofia;
        City warsaw;
        City vilnus;
        City madrid;
        City moscow;
        City tbilisi;
        City astana;
        */
        public Searcher()
        {
            visited = new List<City>();

            graph = new GraphImpl();

          
            /*airports = new List<City>();
            aalborg = new City("Aalborg", "Denmark");
            copenhagen = new City("Copenhagen", "Denmark");
            aarhus = new City("Aarhus", "Demnark");
            berlin = new City("Berlin", "Germany");
            budapest = new City("Budapest", "Romania");
            sofia = new City("Sofia", "Bulagria");
            warsaw = new City("Warsaw", "Poland");
            vilnus = new City("Vilnus", "Lithuania");
            madrid = new City("Madrid", "Spain");
            moscow = new City("Moscow", "Russia");
            tbilisi = new City("Tblisi", "Georgia");
            astana = new City("Astana", "Kazakhstan");

            visited = new List<City>();

            graph = new GraphImpl();


            graph.AddCity(aalborg);
            graph.AddCity(copenhagen);
            graph.AddCity(aarhus);
            graph.AddCity(berlin);
            graph.AddCity(budapest);
            graph.AddCity(sofia);
            graph.AddCity(warsaw);
            graph.AddCity(vilnus);
            graph.AddCity(madrid);
            graph.AddCity(moscow);
            graph.AddCity(tbilisi);
            graph.AddCity(astana);
            graph.AddFlight(aalborg, copenhagen);
            graph.AddFlight(aarhus, copenhagen);
            graph.AddFlight(copenhagen, aalborg);
            graph.AddFlight(copenhagen, aarhus);
            graph.AddFlight(copenhagen, berlin);
            graph.AddFlight(aalborg, berlin);
            graph.AddFlight(berlin, moscow);
            graph.AddFlight(moscow, tbilisi);
            graph.AddFlight(tbilisi, astana);
            graph.AddFlight(berlin, copenhagen);
            graph.AddFlight(berlin, budapest);
            graph.AddFlight(berlin, warsaw);
            graph.AddFlight(warsaw, berlin);
            graph.AddFlight(budapest, berlin);
            graph.AddFlight(sofia, budapest);
            graph.AddFlight(berlin, sofia);
            graph.AddFlight(warsaw, vilnus);
            graph.AddFlight(vilnus, warsaw);
            graph.AddFlight(vilnus, berlin);
            graph.AddFlight(berlin, astana);
            graph.AddFlight(madrid, berlin);
            graph.AddFlight(berlin, madrid);
            graph.AddFlight(madrid, sofia);
            graph.AddFlight(budapest, sofia);
            graph.AddFlight(astana, budapest);
            graph.AddFlight(berlin, aalborg);
            graph.AddFlight(warsaw, madrid);
             * */
        
        
        
        }
        public void MakeAGraph(IList<City> airports, IList<Flight> flights)
        {
            foreach(City c in airports)
            {
                graph.AddCity(c);
            }
            foreach(Flight f in flights)
            {
                City theCityFrom = f.From;
                City theCityTo = f.To;
                graph.AddFlight(theCityFrom, theCityTo);
            }
        }
        
        
        public IGraphImpl ReturnGraph()
        {
            return graph;
        }
        public void MakeASearchInGraph(City from, City to)
        {
            ListOfConnections listOfConnections = new ListOfConnections();
            listOfConnections = graph.SearchForConnections(from, to);
            foreach (Connection a in listOfConnections.GetConnectionList())
            {
                Console.WriteLine("******");
                foreach (Flight g in a.FlightList())
                {
                    Console.WriteLine(g.From.Name + " ---> " + g.To.Name);
                }
            }

            
          
 

            
        

        }
    }
}